<template>
    <div class="home">
        <header-nav></header-nav>
        <div class="container">
            <side-bar></side-bar>
            <div class="content">
                <div class="panel">
                    <div class="header">
                        <span class="topic-tab">{{user_name}} 收藏的话题</span>
                    </div>
                    <div class="inner no-padding">
                        <div class="topic_list clear">
                            <div class="cell" v-for="(item, index) in topics" :key="index">
                                 
                                <!-- <div class="reply_count left">
                                    <span class="count_of_replies" title="回复数">{{item.reply_count}}</span>
                                    <span>/</span>
                                    <span class="count_of_visits" title="点击数">{{item.visit_count}}</span>
                                </div> -->
                                <router-link class="last-time right" :to="'/'">
                                    <!-- <img :src="require('@/assets/images/avatar.jpg')" class="user_small_avatar" alt=""> -->
                                    <span class="last_active_time" v-if="item.last_reply_at !== null">最新动态 {{days(item.last_reply_at)}}</span>
                                </router-link>
                                <div class="topic_title_wrapper">
                                    <span class="type_tag type_share">{{item.tab_value}}</span>
                                    <router-link :to="'/topic/' + item._id" class="topic_title ellipsis">{{item.title}}</router-link>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import HeaderNav from "@/components/header/header"
import SideBar from "@/components/sidebar/sidebar"
import { getCollections } from "@/service/api"
import { relativeTime } from "@/config/mUtils"

export default {
    data() {
        return {
            topics: [], 
            user_name: ''
        }
    },
    mounted() {
        this.user_name = this.$route.params.name
        this.getCollectionsFuc()
    },
    methods: {
        days(time) {
            return relativeTime(time)
        },
        async getCollectionsFuc(query) {
            this.current = query

            let param = {
                loginName: this.user_name
            }

            let res = await getCollections(param)

            if(res.code) {
                this.topics = res.result
                // console.log(this.topics)
            }
        }
    },
    components: {
        HeaderNav,
        SideBar
    }
}
</script>


<style lang="scss" scoped>
    @import '../../style/mixin.scss';

    .home {
        .container {
            margin-top: 10px;
            .topic-tab {
                font-size: 14px;
                color: $main;
                margin: 0 5px;
                padding: 3px 4px;
                border-radius: 3px;
                cursor: pointer;
            }
            .current-tab {
                background-color: $main;
                color: $fff;
            }
            .topic_list {
                margin: 0;
                .cell {
                    .user_avatar {
                        font-size: 16px;
                        color: $color3;
                    }
                    &:hover {
                        background-color: $title-bg;
                    }
                    border-bottom: 1px solid $title-bg;
                    padding: 10px;
                    float: left;
                    width: 100%;
                    img {
                        width: 30px;
                        height: 30px;
                        border-radius: 3px;
                        vertical-align: middle;
                    }
                    .reply_count {
                        width: 70px;
                        text-align: center;
                        .count_of_replies {
                            font-size: 16px;
                            color: $org;
                        }
                        .count_of_visits {
                            color: $color7;
                        }
                    }
                    .last-time {
                        .last_active_time {
                            text-align: right;
                            min-width: 50px;
                            display: inline-block;
                            white-space: nowrap;
                            color: $gray;
                            font-size: 12px;
                        }
                    }
                    .topic_title_wrapper {
                        padding-right: 100px;
                    }
                    
                }
            }
        }
    }
    
</style>

